home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / ape-ad1a / cdxvbspr.cls < prev    next >
Text File  |  1998-11-08  |  2KB  |  71 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. END
  5. Attribute VB_Name = "CDXVBSprite"
  6. Attribute VB_GlobalNameSpace = False
  7. Attribute VB_Creatable = True
  8. Attribute VB_PredeclaredId = False
  9. Attribute VB_Exposed = False
  10. Public x As Long
  11. Public y As Long
  12. Public XVel As Long
  13. Public YVel As Long
  14.  
  15. Public m_lpDDS As New CDXVBSurface
  16. Private Boundry As RECT
  17.  
  18. Private m_lpdd As CDXVBScreen
  19.  
  20. Public Sub Create(FileName As String, DDraw As CDXVBScreen, top As Integer, bottom As Integer, left As Integer, right As Integer)
  21.       x = 0
  22.       y = 0
  23.  
  24.       m_lpDDS.Create FileName, DDraw
  25.  
  26.       Set m_lpdd = DDraw
  27.  
  28.       With Boundry
  29.             .top = top
  30.             .bottom = bottom
  31.             .left = left
  32.             .right = right
  33.       End With
  34. End Sub
  35.  
  36. Private Sub Class_Terminate()
  37.       Set m_lpDDS = Nothing
  38. End Sub
  39.  
  40. Public Sub Draw()
  41.       Call m_lpDDS.Blit(x, y, m_lpdd.m_lpDDSBack)
  42. End Sub
  43.  
  44. Public Sub SetXYVel(nXVel As Long, nYVel As Long)
  45.       XVel = nXVel
  46.       YVel = nYVel
  47. End Sub
  48.  
  49. Public Sub Move()
  50.       If (x + XVel < Boundry.left) Then
  51.             x = Boundry.left
  52.       ElseIf (x + XVel > Boundry.right) Then
  53.             x = Boundry.right
  54.       Else
  55.             x = x + XVel
  56.       End If
  57.  
  58.       If (y + YVel < Boundry.top) Then
  59.             y = Boundry.top
  60.       ElseIf (y + YVel > Boundry.bottom) Then
  61.             y = Boundry.bottom
  62.       Else
  63.             y = y + YVel
  64.       End If
  65. End Sub
  66.  
  67. Public Sub SetXY(nX As Long, nY As Long)
  68.       x = nX
  69.       y = nY
  70. End Sub
  71.